<?php
/**
 * Created by PhpStorm.
 * User: sunqiang
 * Date: 2018/8/29
 * Time: 下午5:09
 */

namespace common\service;

use Yii;

class ShopService
{

    public static function findShopByIds($shopIds)
    {
        if (!is_array($shopIds)) {
            $shopIds = array($shopIds);
        }


        $str_shopIds = implode(',', $shopIds);

        $sql = 'SELECT * FROM `j_shop` WHERE `Status` != 0 AND FIND_IN_SET(ShopID,:ids)';
        $cmd = Yii::$app->db->createCommand($sql);
        $cmd->bindParam(':ids', $str_shopIds, \PDO::PARAM_STR);

        return $cmd->queryAll();


    }

    public static function findAll()
    {
        $sql = 'SELECT * FROM `j_shop` WHERE `Status` != 0';
        return Yii::$app->db->createCommand($sql)->queryAll();
    }


    public static function findWarehouseShopGroupAll()
    {
        $sql = 'SELECT id,name,warehouseIds,shopIds FROM j_warehouse_shop_group WHERE useFlg=1';
        $ws_groups = Yii::$app->db->createCommand($sql)->queryAll();
        return $ws_groups;
    }


}